package com.szzg10.thinking.chapter11;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class SimpleInteration {

	public static void main(String[] args) {
		List<Pet> pets = new ArrayList<Pet>();
		pets.add(new Rat());
		pets.add(new Manx());
		pets.add(new Cymric());
		pets.add(new Mutt());
		pets.add(new Pug());
		pets.add(new Cymric());
		pets.add(new Rat());
		pets.add(new Manx());
		pets.add(new Cymric());
		pets.add(new Mutt());
		pets.add(new Pug());
		pets.add(new Cymric());
		
		Iterator<Pet> iterator = pets.iterator();
		while(iterator.hasNext()) {
			Pet element = iterator.next();
			System.out.println(element);
		}
		System.out.println();
		
		for(Pet element: pets) {
			System.out.println(element);
		}
		System.out.println();
		
		iterator = pets.iterator();
		for(int i = 0; i < 6; i++) {
			iterator.next();
			iterator.remove();
		}
		
		System.out.println(pets);
	}
}
